package drds.data_propagate.binlog.event.mariadb;

import drds.data_propagate.binlog.Buffer;
import drds.data_propagate.binlog.event.FormatDescriptionEvent;
import drds.data_propagate.binlog.event.Header;
import drds.data_propagate.binlog.event.IgnorableEvent;

/**
 * mariadb的ANNOTATE_ROWS_EVENT类型
 *
 * @author jianghang 2014-1-20 下午2:20:35
 * @since 1.0.17
 */
public class AnnotateRowsEvent extends IgnorableEvent {

    private String rowsQuery;

    public AnnotateRowsEvent(Header header, Buffer buffer, FormatDescriptionEvent formatDescriptionEvent) {
        super(header, buffer, formatDescriptionEvent);

        final int commonHeaderLen = formatDescriptionEvent.getCommonHeaderLength();
        final int postHeaderLen = formatDescriptionEvent.getEventPostHeaderLength()[header.getEventType() - 1];

        int offset = commonHeaderLen + postHeaderLen;
        int len = buffer.limit() - offset;
        rowsQuery = buffer.getFullString(offset, len, Buffer.ISO_8859_1);
    }

    public String getRowsQuery() {
        return rowsQuery;
    }

}
